package com.software.backend.center.service;

import org.springframework.stereotype.Service;

import javax.servlet.http.HttpServletResponse;
import java.io.*;
import java.net.URI;
import java.util.Base64;

/**
 * @author 王俊坤
 * @version 1.0
 * @date 2023/4/19 10:59
 */

@Service
public class PersonnelCenterServiceImpl implements PersonnelCenterService{

    @Override
    public String getPeresonnelHead(String url) {
        File imageFile = new File(url);
        if (imageFile.exists()) {
            FileInputStream inputStream = null;
            try {
                inputStream = new FileInputStream(imageFile);
                byte[] bytes = new byte[(int)imageFile.length()];
                inputStream.read(bytes);
                inputStream.close();
                return Base64.getEncoder().encodeToString(bytes);
            } catch (IOException e) {
                e.printStackTrace();
                return null;
            }
        } else {
            return null;
        }
    }
}
